-
Notifications
You must be signed in to change notification settings - Fork 2.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
zsh: added compdef call to support direct sourcing #887
Conversation
@rsteube travis has failed. Seems unconnected to me though. Can you rebase/merge and see if the problem persists? |
Seems the shellcheck still fails on master: https://travis-ci.org/spf13/cobra/builds/546829202 |
Are you aware if anybody is taking care of the failing master? |
Haven't seen a related PR/Issue yet. |
as suggested by @corneliusweig
2b3f9b2
to
50ef1a2
Compare
Would be nice to see this land in master 😄 |
We hit the same problem :( Would be great if this gets merged :) |
ping @jharshman... |
Any idea when this can be merged? @jharshman @corneliusweig @rsteube |
@spf13 Could you get this in? Several projects are blocked on autocompletion issues |
@jharshman @spf13 someone, please? |
Anyone that depends on this can use https://github.com/rsteube/cobra-zsh-gen for now. |
One I can think of right away is There have see at least 2 other issues where people have tried to do |
@jharshman yes, using |
@rsteube @epk thank you for explaining the use case as well as your patience during the review process. It is my opinion that this is not a bug, nor an improvement. The usage of ZSH completions is well documented here, and follows the recommended method of sourcing completions and functions outlined in the documentation for ZSH. |
@jharshman I beg to differ here, I do think this is a bug. Many projects feature a sub-commands like [1] Other projects I know which follow the same pattern: |
The vanilla version assumes that the completion script is generated once and then put in the zsh completion script folder. This has advantages, such as better caching, but it breaks the most common use-case `source <(rakkess completion zsh)` This commit adds a compdef call which re-enables this usage. Also see spf13/cobra#887
The vanilla version assumes that the completion script is generated once and then put in the zsh completion script folder. This has advantages, such as better caching, but it breaks the most common use-case `source <(rakkess completion zsh)` This commit adds a compdef call which re-enables this usage. Also see spf13/cobra#887
FWIW, the compdef call can be added manually, see https://github.com/corneliusweig/rakkess/blob/eb1ac91e5cddba8f3fbb14d88fff6e863738d8a8/cmd/completion.go#L78 for an example. |
So far, Skaffold used a wrapper code borrowed from kubectl to use the bash completion script for zsh. Cobra v0.0.5 introduced a native completion script generator for zsh. To support the `source <(...)` use-case, a minor tweak is necessary (also see spf13/cobra#887) Signed-off-by: Cornelius Weig <22861411+corneliusweig@users.noreply.github.com>
* Use native zsh completion script generator So far, Skaffold used a wrapper code borrowed from kubectl to use the bash completion script for zsh. Cobra v0.0.5 introduced a native completion script generator for zsh. To support the `source <(...)` use-case, a minor tweak is necessary (also see spf13/cobra#887) Signed-off-by: Cornelius Weig <22861411+corneliusweig@users.noreply.github.com> * Do not explicitly ignore write errors
as suggested by @corneliusweig
fixes #881